<template>
  <div id="quesAdmin">
    <!--使用公共头部区-->
    <c-header :classId1="className"></c-header>
    <!--题库管理主体区-->
    <div class="Adm-body">
      <div class="Adm-header">
        <el-row>
          <el-col :span="4" class="elColOne">题库管理</el-col>
          <el-col :span="4" :offset="16" class="elColTwo">
            <el-button type="primary" @click="isshow=!isshow">新增题目</el-button>
          </el-col>
        </el-row>
      </div>
      <div class="Adm-content">
        <div class="con-left">
          <h5>题目分类</h5>
          <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick">
          </el-tree>
          <div class="btn">
            <button @click="isaddmask=!isaddmask">编辑/添加分类</button>
          </div>
        </div>
        <transition name="fade">
        <div class="con-right" v-show="isshow">
          <div class="ri-content">
            <div class="rc-header">
              <span>题目标题</span><el-input v-model="rcinput" placeholder="请输入内容"></el-input>
              <span>题目分类</span>
              <el-select v-model="rcvalue" placeholder="请选择分类">
                <el-option v-for="rcitem in rcoptions" :key="rcitem.rcvalue" :label="rcitem.rclabel" :value="rcitem.rcvalue">

                </el-option>
              </el-select>
            </div>
            <div class="rc-rule">
              <span>答题规则</span>
              <el-select v-model="ruvalue" placeholder="请选择规则">
                <el-option v-for="ruitem in ruoptions" :key="ruitem.ruvalue" :label="ruitem.rulabel" :value="ruitem.ruvalue">

                </el-option>
              </el-select>
              <ul>
                <li><input type="text" value="非常不满意"> <i class="el-icon-close"></i></li>
                <li><input type="text" value="不满意"> <i class="el-icon-close"></i></li>
                <li><input type="text" value="一般"> <i class="el-icon-close"></i></li>
                <li><input type="text" value="比较满意"> <i class="el-icon-close"></i></li>
                <li><input type="text" value="非常满意"> <i class="el-icon-close"></i></li>
              </ul>
            </div>
            <div class="rc-btn">
              <button class="rcb1">取消</button>
              <button class="rcb2">保存</button>
            </div>
          </div>
          <div class="ri-footer">
            <button @click="ismask=!ismask">删除题目</button>
          </div>
        </div>
        </transition>
      </div>
    </div>
    <!--删除题目遮罩层-->
    <transition name="fade">
    <div class="hidden mask" v-if="ismask">
      <div class="m-content">
        <p class="p1">确定删除该题目？<i class="el-icon-close" v-model="ismask" @click="ismask=!ismask"></i></p>
        <p class="p2">您对xxx是否满意？</p>
        <div class="mask-btn">
          <button class="mbtn1" v-model="ismask" @click="ismask=!ismask">取消</button>
          <button class="mbtn2">确定</button>
        </div>
      </div>
    </div>
    </transition>
    <!--编辑/添加分类遮罩层-->
    <transition name="fade">
    <div class="addhidden addmask" v-if="isaddmask">
      <div class="addm-content">
        <div class="adconleft">
          <h3>编辑分类</h3>
          <ul>
            <li v-for="title in data">
              <el-input v-model="title.label" clearable>
              </el-input>
            </li>
          </ul>
          <button class="adcleft1">重置</button>
          <button class="adcleft2">确认</button>
        </div>
        <div class="adconright">
          <h3>添加分类</h3>
          <div class="addClassify">
          	<el-input placeholder="请添加分类" class="input-with-select">
					    <el-button slot="append">添加</el-button>
					  </el-input>
          </div>          
        </div>
        <i id="close" class="el-icon-close" @click="isaddmask=!isaddmask"></i>
        <div class="finally-btn">
        	<button class="btn1" @click="isaddmask=!isaddmask">关闭</button>
        	<button class="btn2">修改</button>
        </div>
      </div>
    </div>
    </transition>
  </div>
</template>

<script>
  //导入公共头部组件
  import cHeader from '../common/quesHeader.vue';
  export default {
    data() {
      return {
        className: 'active',
        ismask: false,
        isaddmask: false,
        isshow: false,
        tabPosition: 'left',
        labelMo: '您对xx是否满意？',
        rcinput: '',
        //右侧题目分类下拉框数据
        rcoptions: [{
          rcvalue: '选项1',
          rclabel: '人口特征'
        }, {
          rcvalue: '选项2',
          rclabel: '满意度'
        }, {
          rcvalue: '选项3',
          rclabel: '小区环境'
        }],
        rcvalue: '',
        //右侧答题规则下拉框数据
        ruoptions: [{
          ruvalue: '选项1',
          rulabel: '必选'
        }, {
          ruvalue: '选项2',
          rulabel: '非必选'
        }],
        ruvalue: '',
        //左侧题目分类数据
        data: [{
          label: '满意度',
          children: [{
            label: '您对xx是否满意？'
          }, {
            label: '您是否愿意使用xx？'
          }]
        }, {
          label: '人口属性',
          children: [{
            label: '地域'
          }, {
            label: '出生年月',
          }, {
            label: '职业',
          }]
        }, {
          label: '上网行为',
          children: [{
            label: '电脑'
          }, {
            label: '手机'
          }]
        }],
        defaultProps: {
          children: 'children',
          label: 'label'
        }
      };
    },
    methods: {
      handleNodeClick(data) {
        console.log(data);
      }
    },
    components: {
      "c-header": cHeader
    }
  }
</script>

<style scoped="scoped">
  #quesAdmin {
    min-width: 960px;
    font-family: "微软雅黑";
  }  
  #quesAdmin .Adm-body {
    padding: 0 12px 10px 12px;
  } 
  #quesAdmin .Adm-body .Adm-header {
    height: 55px;
    line-height: 55px;
    width: 100%;
    overflow: hidden;
  }
  .Adm-header .elColOne{
  	padding-left: 10px;
  	color: #409EFF;
  	font-size: 18px;
  	letter-spacing: 2px;
  }
  .Adm-header .elColTwo{
  	text-align: right;
  }  
  #quesAdmin .Adm-header >>> .el-button {
    margin: 0;
    width: 110px;
  }
  /*下边样式区*/  
  #quesAdmin .Adm-content {
    width: 100%;
    height: 87vh;
    border: 1px solid #ccc;
    display: flex;
  }  
  #quesAdmin .con-left {
    height: 87vh;
    width: 250px;
    background-color: rgb(242, 242, 242);
    padding: 15px 0 0 10px;
    box-sizing: border-box;
    overflow: hidden;
  }  
  #quesAdmin .con-left h5 {
    margin: 0;
    padding: 0;
    font-size: 16px;
    font-weight: normal;
  }  
  #quesAdmin .el-tree {
    margin-top: 20px;
  }  
  #quesAdmin >>> .el-tree-node__content {
    background-color: rgb(242, 242, 242);
  }  
  #quesAdmin >>> .el-tree-node__content:hover {
    background-color: #ccc;
  } 
  .con-left .btn {
    margin-top: 20px;
    margin-left: 20px;
  }  
  .con-left .btn button {
    height: 35px;
    line-height: 35px;
    padding: 0 8px;
    border-radius: 5px;
    background-color: rgb(22, 155, 213);
    cursor: pointer;
    outline: none;
    color: #fff;
    border: none;
  } 
  #quesAdmin .con-right {
  	position: relative;
    margin: 20px 0 0 20px;
    box-sizing: border-box;
    overflow: hidden;    
  }  
  #quesAdmin .ri-content {
  	position: relative;
    padding: 10px;
    height: 60vh;
    width: 75vw;
    border: 1px solid #ccc;
    border-radius: 5px; 
  }  
  #quesAdmin .rc-header span {
    margin-right: 5px;
    letter-spacing: 1px;
  }
  .rc-header select{
  	padding: 3px 5px;
  }
  .rc-header .el-input {
    width: 230px;
    margin-right: 20px;
  }  
  #quesAdmin .rc-rule {
    margin-top: 25px;
  }  
  #quesAdmin .rc-rule span {
    margin-right: 1px;
    letter-spacing: 1px;
  }
  #quesAdmin .rc-rule .el-select{
  	width: 100px;
  }  
  #quesAdmin .rc-rule ul {
    list-style: none;
    margin-left: 30px;
  }  
  .rc-rule ul li {
    margin-bottom: 6px;
  } 
  .rc-rule ul li input {
    padding: 3px 10px;
    height: 22px;
    line-height: 22px;
    border: 1px solid #DCDFE6;
    border-radius: 5px;
  }  
  .rc-rule .el-icon-close {
  	color: #DCDFE6;
  }
  .rc-rule .el-icon-close:hover {
  	color: red;
  	cursor: pointer;
  }
  #quesAdmin .rc-btn {
    position: absolute;
    bottom: 20px;
    right: 30px;
  }  
  #quesAdmin .rc-btn .rcb1 {
    width: 160px;
    height: 35px;
    line-height: 35px;
    text-align: center;
    border: none;
    color: black;
    background-color: #ddd;
    margin-right: 20px;
    border-radius: 5px;
    box-sizing: border-box;
    outline: none;
    cursor: pointer;
  }  
  .rc-btn .rcb2 {
    width: 160px;
    height: 35px;
    line-height: 35px;
    text-align: center;
    border: none;
    color: #fff;
    background-color: rgb(22, 155, 213);
    margin-right: 20px;
    border-radius: 5px;
    box-sizing: border-box;
    outline: none;
    cursor: pointer;
  }  
  .ri-footer button {
    width: 300px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    color: #fff;
    background-color: rgb(22, 155, 213);
    position: absolute;
    left: 50%;
    bottom: 5%;
    transform: translateX(-50%);
    box-sizing: border-box;
    outline: none;
    cursor: pointer;
    border: none;
    border-radius: 5px;
  }
  /*删除题目遮罩层*/ 
  #quesAdmin .hidden {
    display: none;
  }  
  #quesAdmin .mask {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, .7);
    z-index: 1;
    display: block;
  }  
  #quesAdmin .mask .m-content {
    height: 300px;
    width: 500px;
    z-index: 100;
    background: #fff;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid #ccc;
    border-radius: 5px;
  }  
  #quesAdmin .m-content .p1 {
  	margin: 0;
    height: 45px;
    line-height: 45px;
    padding-left: 15px;
    border-bottom: 1px solid #ccc;
    font-size: 17px;
    color: rgba(0,0,0,.7);
  }  
  #quesAdmin .m-content .p2 {
    margin-top: 5px;
    margin-left: 2px;
  }  
  .m-content i {
    position: absolute;
    right: 5px;
    top: 15px;
  }  
  .m-content i:hover {
    color: red;
    cursor: pointer;
  }  
  .m-content .p2 {
    width: 80%;
    margin: 20px auto;
    padding-left: 15px;
  }  
  .m-content .mask-btn {
    width: 80%;
    margin: 100px auto 10px;
    text-align: center;
  } 
  .m-content .mask-btn button {
    width: 150px;
    height: 35px;
    line-height: 35px;
    border-radius: 5px;
    text-align: center;
    cursor: pointer;
    outline: none;
    border: none;
  }  
  .m-content .mask-btn .mbtn1 {
    background-color: #fff;
    border: 1px solid #DCDFE6;
    color: #666;
    letter-spacing: 2px;
    margin-right: 5px;
  }  
  .m-content .mask-btn .mbtn2 {
    background-color: rgb(22, 155, 213);
    color: #fff;
    letter-spacing: 2px;
    margin-left: 5px;
  }
  /*编辑添加分类遮罩层*/  
  #quesAdmin .addhidden {
    display: none;
  }  
  #quesAdmin .addmask {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, .8);
    z-index: 1;
    display: block;
  }  
  #quesAdmin .addmask .addm-content {
    height: 60vh;
    width: 70vw;
    z-index: 100;
    background: #fff;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid black;
    border-radius: 3px;
  }  
  .addm-content .adconleft {
  	position: relative;
    margin: 50px 0px 0 50px;
    float: left;
    background-color: #1580B6;
    height: 40vh;
    width: 25vw;
    text-align: center;
    padding: 10px 10px 0;
    box-sizing: border-box;
    overflow: auto;
    border-radius: 8px;    
  }  
  .adconleft h3 {
    color: #fff;
    font-weight: normal;
    margin: 0;
    padding: 0;
    font-size: 16px;
  }
  .adconleft ul{
  	list-style: none;
  	padding: 0;
  	margin: 0;
  }
  .adconleft ul li{
  	width: 15vw;
  	margin: 20px auto 0;
  }
  .adconleft button{
  	height: 35px;
  	line-height: 35px;
  	text-align: center;
  	width: 7vw;
  	border: none;
  	outline: none;
  	border-radius: 5px;
  	cursor: pointer;
  }
  .adconleft .adcleft1{
  	position: absolute;
  	bottom: 15px;
  	left: 5vw;
  	margin-right: 10px;
  	background-color: #303133;
  	color: #fff;
  }
  .adconleft .adcleft2{
  	position: absolute;
  	bottom: 15px;
  	right: 5vw;
  	margin-left: 10px;
  	background-color: #8CC5FF;
  	color: #EBEEF5;
  }  
  .addm-content .adconright {
    margin: 50px 50px 0 0;
    float: right;
    background-color: #3A8EE6;
    height: 40vh;
    width: 25vw;
    text-align: center;
    padding: 10px 10px 0;
    box-sizing: border-box;
    overflow: auto;
    border-radius: 8px;
    position: relative;
  }  
  .adconright h3 {
    color: #fff;
    font-weight: normal;
    margin: 0;
    padding: 0;
    font-size: 16px;
  }
  .adconright .addClassify{
  	margin: 15vh auto 0;
  	width: 16vw;
  }
  /*修改添加分类按钮样式*/
  #quesAdmin >>> .addClassify .el-button{
  	background-color: #333333;
    color: #fff;
    margin-top: -8px;
    margin-right: -21px;
  }	
	#close{
		position: absolute;
		right: 10px;
		top: 10px;
	}
	.addm-content i:hover{
		color: red;
	}
	.addm-content .finally-btn{
		position: absolute;
		bottom: 10px;
		left: 50%;
		transform: translateX(-50%);
		width: 20vw;
	}
	.addm-content .finally-btn button{
		width: 8vw;
		height: 35px;
		line-height: 35px;
		border: none;
		outline: none;
		border-radius: 5px;
		cursor: pointer;
	}
	.addm-content .finally-btn .btn1{
		margin-right: 10px;
	}
	.addm-content .finally-btn .btn2{
		margin-left: 10px;
		background-color: #1580B6;
		color: #fff;
	}
	/*遮罩层统一动画*/
	.fade-enter {
		opacity: 0;
	}
	.fade-enter-active {
		transition: opacity 1s;
	}
	.fade-leave-to {
		opacity: 0;
	}
	.fade-leave-active {
		transition: opacity 1s;
	}
</style>